]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenshot: Remove shooter from sender in finally block
authorJonas Dreßler <verdre@v0yd.nl>
Tue, 9 Feb 2021 16:09:05 +0000 (17:09 +0100)
committerMarge Bot <marge-bot@gnome.org>
Thu, 11 Feb 2021 18:51:40 +0000 (18:51 +0000)
We do this in both the try{} and the catch{} block, so we might as well
put it into a finally{} block.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1658>

js/ui/screenshot.js

index 59a6c46aff60d9b5be84edce57c3937024d515bb..583f8b7c54caa7d7ec5826ddc21924af9dc99993 100644 (file)
@@ -200,10 +200,10 @@ var ScreenshotService = class {
                 screenshot.screenshot_area(x, y, width, height, stream),
             ]);
             this._onScreenshotComplete(stream, file, invocation);
-            this._removeShooterForSender(invocation.get_sender());
         } catch (e) {
-            this._removeShooterForSender(invocation.get_sender());
             invocation.return_value(new GLib.Variant('(bs)', [false, '']));
+        } finally {
+            this._removeShooterForSender(invocation.get_sender());
         }
     }
 
@@ -223,10 +223,10 @@ var ScreenshotService = class {
                 screenshot.screenshot_window(includeFrame, includeCursor, stream),
             ]);
             this._onScreenshotComplete(stream, file, invocation);
-            this._removeShooterForSender(invocation.get_sender());
         } catch (e) {
-            this._removeShooterForSender(invocation.get_sender());
             invocation.return_value(new GLib.Variant('(bs)', [false, '']));
+        } finally {
+            this._removeShooterForSender(invocation.get_sender());
         }
     }
 
@@ -246,10 +246,10 @@ var ScreenshotService = class {
                 screenshot.screenshot(includeCursor, stream),
             ]);
             this._onScreenshotComplete(stream, file, invocation);
-            this._removeShooterForSender(invocation.get_sender());
         } catch (e) {
-            this._removeShooterForSender(invocation.get_sender());
             invocation.return_value(new GLib.Variant('(bs)', [false, '']));
+        } finally {
+            this._removeShooterForSender(invocation.get_sender());
         }
     }